#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;
int main() {
	string st1;
	string st2;
	int count = 0;
	cin >> st1 >> st2;
	auto it1 = st1.begin();
	auto it2 = st2.begin();
	auto it2_poi = st2.begin();
	while (it2 != st2.end())
	{
		int num = 0; while (it1 != st1.end() && it2 != st2.end() && *it1 == *it2)
		{
			num++;
			it1++;
			it2++;
		}
		if (num > count)
			count = num;
		if (it2 == st2.end())
			break;
		else
			it2 = it2_poi;
		while (*it1 != *it2 && it1 != st1.end()) {
			it1++;
		}
		if (it1 == st1.end())
		{
			it2++;
			it1 = st1.begin();
			it2_poi = it2;
		}
	}
	int bigsize = st1.size() > st2.size() ? st1.size() : st2.size();
	int cvl = bigsize - count;
	cout << cvl << endl;
	return 0;
}
